import { createHashHistory } from 'history';

const hashHistory = createHashHistory();

class Router {
  history: any;
  location: {
    hash: string;
    pathname: string;
    search: string;
    state: any;
  };

  constructor() {
    this.history = hashHistory;
    // this.location = this.history.location;
  }

  push(path: string, state?: any) {
    hashHistory.push(path, state);
  }

  replace(path: string, state?: any) {
    hashHistory.replace(path, state);
  }

  listen(callback: any) {
    hashHistory.listen(route => {
      console.log(route);
    });
  }
}

const $router = new Router();

export default $router;
